added gtk_container_child_set_property() and
authorTim Janik <timj@gtk.org>
Thu, 21 Jun 2001 00:42:46 +0000 (00:42 +0000)
committerTim Janik <timj@src.gnome.org>
Thu, 21 Jun 2001 00:42:46 +0000 (00:42 +0000)
Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>

        * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
        gtk_container_child_get_property().

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcontainer.c
gtk/gtkcontainer.h

index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index 82c930c1344f4b48ec5a4f7d86f3922b39f9b7bd..0c97a5280414522100d3919bd0d6d106d9693dd5 100644 (file)
@@ -1,3 +1,8 @@
+Thu Jun 21 02:13:40 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkcontainer.[hc]: added gtk_container_child_set_property() and
+       gtk_container_child_get_property().
+
 Wed Jun 20 19:19:15 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreeview.c (gtk_tree_view_move_cursor_up_down): clean up
index ddd18f2fb3927e2e56cb0b5105b00eebddf53931..f0a587af321144b8b32bd930ce55e5a7d0d04226 100644 (file)
@@ -379,6 +379,71 @@ gtk_container_child_get_valist (GtkContainer *container,
   g_object_unref (container);
 }
 
+void
+gtk_container_child_get_property (GtkContainer *container,
+                                 GtkWidget    *child,
+                                 const gchar  *property_name,
+                                 GValue       *value)
+{
+  GParamSpec *pspec;
+
+  g_return_if_fail (GTK_IS_CONTAINER (container));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (child->parent == GTK_WIDGET (container));
+  g_return_if_fail (property_name != NULL);
+  g_return_if_fail (G_IS_VALUE (value));
+  
+  g_object_ref (container);
+  g_object_ref (child);
+  pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name,
+                                   G_OBJECT_TYPE (container), TRUE);
+  if (!pspec)
+    g_warning ("%s: container class `%s' has no child property named `%s'",
+              G_STRLOC,
+              G_OBJECT_TYPE_NAME (container),
+              property_name);
+  else if (!(pspec->flags & G_PARAM_READABLE))
+    g_warning ("%s: child property `%s' of container class `%s' is not readable",
+              G_STRLOC,
+              pspec->name,
+              G_OBJECT_TYPE_NAME (container));
+  else
+    {
+      GValue *prop_value, tmp_value = { 0, };
+
+      /* auto-conversion of the callers value type
+       */
+      if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec))
+       {
+         g_value_reset (value);
+         prop_value = value;
+       }
+      else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value)))
+       {
+         g_warning ("can't retrive child property `%s' of type `%s' as value of type `%s'",
+                    pspec->name,
+                    g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+                    G_VALUE_TYPE_NAME (value));
+         g_object_unref (child);
+         g_object_unref (container);
+         return;
+       }
+      else
+       {
+         g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+         prop_value = &tmp_value;
+       }
+      container_get_child_property (container, child, pspec, prop_value);
+      if (prop_value != value)
+       {
+         g_value_transform (prop_value, value);
+         g_value_unset (&tmp_value);
+       }
+    }
+  g_object_unref (child);
+  g_object_unref (container);
+}
+
 void
 gtk_container_child_set_valist (GtkContainer *container,
                                GtkWidget    *child,
@@ -445,6 +510,48 @@ gtk_container_child_set_valist (GtkContainer *container,
   g_object_unref (child);
 }
 
+void
+gtk_container_child_set_property (GtkContainer *container,
+                                 GtkWidget    *child,
+                                 const gchar  *property_name,
+                                 const GValue *value)
+{
+  GObject *object;
+  GObjectNotifyQueue *nqueue;
+  GParamSpec *pspec;
+
+  g_return_if_fail (GTK_IS_CONTAINER (container));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (child->parent == GTK_WIDGET (container));
+  g_return_if_fail (property_name != NULL);
+  g_return_if_fail (G_IS_VALUE (value));
+  
+  g_object_ref (container);
+  g_object_ref (child);
+
+  object = G_OBJECT (container);
+  nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
+  pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name,
+                                   G_OBJECT_TYPE (container), TRUE);
+  if (!pspec)
+    g_warning ("%s: container class `%s' has no child property named `%s'",
+              G_STRLOC,
+              G_OBJECT_TYPE_NAME (container),
+              property_name);
+  else if (!(pspec->flags & G_PARAM_WRITABLE))
+    g_warning ("%s: child property `%s' of container class `%s' is not writable",
+              G_STRLOC,
+              pspec->name,
+              G_OBJECT_TYPE_NAME (container));
+  else
+    {
+      container_set_child_property (container, child, pspec, value, nqueue);
+    }
+  g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
+  g_object_unref (container);
+  g_object_unref (child);
+}
+
 void
 gtk_container_add_with_properties (GtkContainer *container,
                                   GtkWidget    *widget,
index 566b7d638c519c53eea04a9f36bebbdb0d04a951..d8a9db2af59506483193180c87f18aee83f665d0 100644 (file)
@@ -177,7 +177,15 @@ void         gtk_container_child_get_valist                (GtkContainer      *container,
                                                         GtkWidget         *child,
                                                         const gchar       *first_property_name,
                                                         va_list            var_args);
-
+void        gtk_container_child_set_property           (GtkContainer      *container,
+                                                        GtkWidget         *child,
+                                                        const gchar       *property_name,
+                                                        const GValue      *value);
+void        gtk_container_child_get_property           (GtkContainer      *container,
+                                                        GtkWidget         *child,
+                                                        const gchar       *property_name,
+                                                        GValue            *value);
+     
 
 #define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
     G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))